<?php
// HTTP GET/POST REQUEST HANDLER
if(count($_GET)>0)
{
    include '../serverInfo.php';
    include '../lib/mySqlHelper.php';
    $mysqlh = new MySqlHelper(ServerInfo::HOST,ServerInfo::PORT,ServerInfo::USERNAME,ServerInfo::PASSWORD);
    if(!$mysqlh->connect())
    {
        echo mysql_errno()." ".mysql_error();
        die;
    }
    if($_GET['action']=="getSchemas")
    {
        $schemas = $mysqlh->getSchemas();
        foreach($schemas as $schema)
        {
                echo "<div class='schema' id='".$schema."'  onclick='getTables(this);'>".$schema."</div>";
                echo "<div class='tablepane' id='".$schema."_'></div>";
        }
        return;
    }
    else if($_GET['action']=="getTables")
    {
        $tables = $mysqlh->getTables($_GET['schema']);
        foreach($tables as $table)
        {
                echo "<div id='".$_GET['schema']."_".$table."' onclick='descTable(\"".$_GET['schema']."\",\"".$table."\",this);'>".$table."</div>";
        }
        return;
    }
}
?>